package org.kingtop.shiro.jwt;

import org.apache.shiro.authc.AuthenticationToken;

import java.util.Date;

/**
 * jwt token，用于jwt token的验证
 * @author 陈金波
 * @date 2018/2/9 20:38
 */
public class JwtAuthenticationToken implements AuthenticationToken {

    /**
     * 构造函数
     * @param token jwt token
     */
    public JwtAuthenticationToken(String token) {
        this.token = token;
    }

    @Override
    public Object getPrincipal() {
        return subject;
    }

    @Override
    public Object getCredentials() {
        return id;
    }

    /**
     * jwt token
     */
    private String token;

    /**
     * 当前用户ID
     */
    private String id;
    /**
     * 用户名
     */
    private String subject;

    /**
     * 签发时间
     */
    private Date issuedAt;

    /**
     * 如果当前时间在nbf里的时间之前，则Token不被接受
     */
    private Date notBefore;

    /**
     * 过期时间，Unix时间戳
     */
    private Long expire;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public Date getIssuedAt() {
        return issuedAt;
    }

    public void setIssuedAt(Date issuedAt) {
        this.issuedAt = issuedAt;
    }

    public Date getNotBefore() {
        return notBefore;
    }

    public void setNotBefore(Date notBefore) {
        this.notBefore = notBefore;
    }

    public Long getExpire() {
        return expire;
    }

    public void setExpire(Long expire) {
        this.expire = expire;
    }

}
